<?php
class APF_DB_PDOStatement extends PDOStatement {
    protected function __construct($pdo) {
        $this->pdo = $pdo;
    }

    protected $pdo;

    public function execute($input_parameters=NULL) {
        if (APF::get_instance()->is_debug_enabled()) {
            APF::get_instance()->debug(__CLASS__ .'['. $this->pdo->config['dsn'] .'|'.$this->pdo->get_name().']'. "->execute: " . $this->queryString);
        }
        $logger = APF::get_instance()->get_logger();
        $logger->debug(__CLASS__, '['. $this->pdo->get_name() .']->execute: ', $this->queryString);

        $ret = parent::execute($input_parameters);
        if (!$ret) {
            $logger->error(__CLASS__, '['. $this->pdo->get_name() .']->execute: ', $this->queryString);
            $error_info = parent::errorInfo();
            if (parent::errorCode() !== '00000') {
                trigger_error($this->queryString.' | '.join(' | ',$error_info),E_USER_ERROR);
            }
        }

        return $ret;
    }
}
